<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script src="../jq/jquery-1.11.3.js"></script>
    <script src="../jq/jquery-3.2.1.js"></script>
</head>
<body>
    <form id="reg-form">
        <div>欢迎注册</div>
        <div>username:</div>
        <div><input name="username"></div>
        <div>password:</div>
        <div><input name="pwd"></div>
        <div>email:</div>
        <div><input name="email"></div>
        <div><input id="reg-btn" type="button" value="注册"></div>
    </form>
</body>
    <script>
        $("#reg-btn").click(function () {
            var url = "../user/register.do";
            var data = $("#reg-form").serialize();
            console.log("data: " + data);

            $.ajax({
                "url" : url,
                "data" : data,
                "type" : "POST",
                "dataType" : "json",
                "success" : function (json) {
                    if(json.state == 200){
                        alert("注册成功！");
                    }else{
                        alert(json.message);
                    }
                }
            });
        })
    </script>
</html>